package com.eqdd.yiqidian.ui.gongneng.renshi.finance

import android.os.Bundle
import com.eqdd.yiqidian.R

import com.eqdd.yiqidian.bean.CheckerBean
import com.eqdd.yiqidian.http.HttpCallBack
import com.eqdd.yiqidian.http.HttpConfig
import com.eqdd.yiqidian.http.HttpResult
import com.eqdd.yiqidian.utils.ToastUtil
import com.lzy.okgo.OkGo
import com.lzy.okgo.model.Response
import android.support.v7.widget.OrientationHelper
import android.support.v7.widget.LinearLayoutManager
import com.eqdd.yiqidian.kotlin.KotlinBaseActivity
import kotlinx.android.synthetic.main.activity_checker_list.*


class CheckerListActivity : KotlinBaseActivity() {

    private lateinit var adapter: CheckerListAdapter

    override fun onCreate(savedInstanceState: Bundle?) {
        setContentView(R.layout.activity_checker_list)
        super.onCreate(savedInstanceState)
        val layoutManager = LinearLayoutManager(this)
        adapter = CheckerListAdapter(this)
        recyclerView.layoutManager = layoutManager
        layoutManager.orientation = OrientationHelper.VERTICAL
        recyclerView.adapter = adapter

        initTopBar("审核人")
    }


    override fun initData() {


        OkGo.post<HttpResult<List<CheckerBean>>>(HttpConfig.BASE_URL + HttpConfig.SELECT_CAREER_ALL)
                .params("comid", user?.companyId as Int)
                .params("userGuid", user?.guid)
                .execute(object : HttpCallBack<HttpResult<List<CheckerBean>>>(this@CheckerListActivity) {

                    override fun onSuccess(response: Response<HttpResult<List<CheckerBean>>>) {
                        val httpResult = response.body()
                        if (httpResult.status == 200) {
                            ToastUtil.showShort(httpResult.msg)
                            adapter.dataList = httpResult.items
                            adapter.notifyDataSetChanged()
                        }
                    }
                })
    }

}

